package com.zy.controller;

import com.zy.pojo.Jurisdiction;
import com.zy.pojo.Role;
import com.zy.service.JurisdictionService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {
    @Resource
    private JurisdictionService jurisdictionService;

    @GetMapping("/index")
    public String index(Model model){
        Subject subject = SecurityUtils.getSubject();
        Role role = (Role) subject.getPreviousPrincipals();
        Session session = subject.getSession();
        session.setAttribute("loginUser",role);

        List<Jurisdiction> menulist = jurisdictionService.getPerMenus();
        model.addAttribute("menulist",menulist);
        return "index";
    }
}
